package com.dbl.oms.gateway.facade.api;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Created by Administrator on 2017/11/4.
 */
/**
 * 作用：
 * ① 测试服务实例的相关内容
 * ② 为后来的服务做提供
 * @author eacdy
 */
@RestController
@RequestMapping(value="/api")
public class MaintainApi {

    @Autowired
    DiscoveryClient discoveryClient;

    /**
     * 注：@GetMapping("/{id}")是spring 4.3的新注解等价于：
     *
     * @return user信息
     * @RequestMapping(value = "/id", method = RequestMethod.GET)
     * 类似的注解还有@PostMapping等等
     */
    @RequestMapping(value = "/apifindById", method = RequestMethod.GET)
    public String findById() {
        System.out.print("MaintainApi-0-0=-0findById-=0-=0-=0-=0-=0=-0-=0-=0=-0=");
        return "4545646465";
    }

    /**
     * 本地服务实例的信息
     *
     * @return
     */
    @RequestMapping(value = "/apiinstance", method = RequestMethod.GET)
    public ServiceInstance showInfo() {
        System.out.print("MaintainApi-0-0=-0findById-=0-=0-=0-=0-=0=-0-=0-=0=-0=");
        ServiceInstance localServiceInstance = this.discoveryClient.getLocalServiceInstance();
        return localServiceInstance;
    }
}
